package keyWords.myFinal;

/**
 * @author
 */
public class Final1 {

    /**
     * 对final不可变量赋值的三种方法：直接赋值、构造方法、代码块
     */
    static class Test {
        // 用构造方法为不可变属性赋值
        private final int n;

        private int m;

        Test(int n) {
            this.n = n;
        }

        // 如果有多个构造方法，每个构造方法都要有对n的初始化
        public Test(int n, int m) {
            this.m = m;
            this.n = n;
        }

        // 未初始化n，编译不通过
//        public Test(int m) {
//            this.m = m;
//        }



    }

    static class Home {
        private final int price;

        {
            price = 999;
        }
    }


}

class Hours {
    private final int price;

    {
        this.price = 999;
    }
}
